

//
//  FunctionViewController.swift
//  Swift 3.0 基础语法
//
//  Created by YYY on 2017/7/17.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import UIKit

class FunctionViewController: CommonViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        
        //[unowned self]
        print(self.view)
        /*
        print(demo1(x: 30, y: 90))
        
        print("-----")
        
        //外部参数
        print(demo2(number1: 5, number2: 50))
        
        print("-----")
        
        print(demo3(30, 60))
        
        print("-----")
        print(demo4())
        print(demo4(x: 100, y: 200))
        print(demo4(x: 20))
        print(demo4(y: 30))
        */
        demo5()
        demo6()
        demo7()
        
        // Do any additional setup after loading the view.
    }

    func demo1(x: Int,y: Int) -> Int
    {
        let sum = x + y
        return sum
    }
    
    func demo2(number1 x:Int,number2 y:Int) -> Int
    {
        let sum = x + y
        return sum
    }
    
    func demo3(_ x: Int,_ y:Int) -> Int
    {
        let sum = x + y
        // 在Swift中，_用来忽略任意不感兴趣的内容
        for _ in 0..<5
        {
            print("没良心")
        }
        return sum
    }
    
    //为参数设置默认值
    func demo4(x: Int = 4,y: Int = 5) -> Int
    {
        let sum = x + y
        return sum
    }
    // MARK: 无返回值
    func demo5() -> Void
    {
        print("你好")
    }
    func demo6() -> ()
    {
        print("憎恨")
    }
    func demo7()
    {
        print("无语")
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    deinit {
        print("销毁当前界面")
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
